import { searchFoods } from "../../service/food"

// pages/search/search.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    searchWord: '',
    foods: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {

  },
  async onSearch() {
    const res = await searchFoods(this.data.searchWord)
    const foods = res.data.foods
    foods.forEach((item: any) => {
      item.count = 0
    });
    this.setData({
      foods: res.data.foods
    })
  }
})